﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using MyECommerceProject.Models;

namespace MyECommerceProject.Data.Configurations
{
    public class ProductConfiguration : IEntityTypeConfiguration<Product>
    {
        public void Configure(EntityTypeBuilder<Product> builder)
        {
            builder.HasKey(p => p.ProductID);
            builder.Property(p => p.Name).IsRequired().HasMaxLength(100);
            builder.Property(p => p.Price).HasColumnType("decimal(18,2)").IsRequired();
            builder.Property(p => p.Category).IsRequired().HasMaxLength(100);
            //builder.Property(p => p.CategoryID).IsRequired();
            //builder.Property(p => p.Brand).HasMaxLength(100);
            builder.Property(p => p.ImageURL).IsRequired().HasMaxLength(200);
            //builder.Property(p => p.IsAvailable).IsRequired();
            builder.Property(p => p.SoldGoods).IsRequired();
            //builder.Property(p => p.CreatedDate).IsRequired().HasDefaultValueSql("GETDATE()");
            //builder.Property(p => p.ModifiedDate).IsRequired(false);
        }
    }
}
